// 云函数入口文件
const cloud = require('wx-server-sdk')
const WXBizDataCrypt = require('./WXBizDataCrypt')
cloud.init()
// 云函数入口函数
exports.main = async (event, context) => {
  var appId = event.userInfo.appId;
  var sessionKey = 'tiihtNczf5v6AKRyjwEUhQ==' 
  var encryptedData = event.encryptedData
   
  var iv = event.iv

  var pc = new WXBizDataCrypt(appId, sessionKey)

  var data = pc.decryptData(encryptedData, iv)
  console.log('解密后 data: ', data)
  return data;
}